package com.cloudkinto.service.order.allocate;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cloudkinto.bo.order.allocate.*;
import com.cloudkinto.bo.order.outbound.ExceptionConfirmBo;
import com.cloudkinto.bo.stock.ProductStockBySkuQueryBo;
import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.entity.AllocatePlanDo;
import com.cloudkinto.vo.order.allocate.AllocatePickingDetail;
import com.cloudkinto.vo.order.allocate.AllocatePlanBatchVo;
import com.cloudkinto.vo.order.allocate.AllocatePlanLockStockVo;
import com.cloudkinto.vo.order.allocate.AllocateProductListVo;
import com.cloudkinto.vo.wr.cost.OrderOutCostReq;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 调拨发货计划 service接口
 * </p>
 *
 * @author long
 * @since 2025-03-11
 */
public interface AllocatePlanService extends IService<AllocatePlanDo> {

    Long add(AllocatePlanAddBo req, Long userId, String username);

    void update(AllocatePlanUpdateBo req, Long userId, String username);

    String generatePlanBatchNo();

    void delete(Long id, Long userId, String username);

    AllocatePlanBatchVo detail(AllocatePlanDetailBo bo, ProductStockBySkuQueryBo productStockBySkuQueryBo);

    SingleResult<Map<String, Object>> pageInit(Long userId, Long tenantId, Long companyId, String source);

    PageResult<AllocatePlanBatchVo> getListPage(AllocatePlanQueryBo bo);

    PageResult<AllocateProductListVo> platformProductListPage(AllocatePlanProductQueryBo bo);

    void markingUrgency(AllocateUrgencyOperateBo bo, Long userId, String username);

    void cancelUrgency(AllocateUrgencyOperateBo bo, Long userId, String username);

    void removePlanItem(AllocatePlanRemoveItemBo bo, Long userId, String username);

    SingleResult<List<Map<String, Object>>> getListPageStatusSta(AllocatePlanQueryBo bo);

    AllocatePlanLockStockVo lockStock(Long batchId, Long tenantId, Long userId, String username);

    void submitOrderToWms(Long batchId, Long userId, String username);

    void unLockStock(Long batchId, Long tenantId, Long userId, String username);

    SingleResult allocateSubmitPick(List<Long> ids, Long userId, String username);

    Map<String, Object> allocatePickingDetailInit(Long userId, Long tenantId, String source);

    AllocatePickingDetail allocatePickingDetail(Long id);

    boolean allocatePicking(AllocatePickingBo bo, Long userId, String username, Long tenantId);

    SingleResult allocateOutboundOperation(Long id, Long userId, String username);

    SingleResult allocateOutboundOperationBatch(List<Long> ids, Long userId, String username);

    /**
     * 根据调拨对象构建出库计费实体
     *
     * @param planDo 调拨发货计划
     * @param status 0实扣 1预扣
     * @return 调拨计算操作费bo
     */
    OrderOutCostReq buildOutboundCostReq(AllocatePlanDo planDo, Integer status);

    SingleResult markException(Long id, Long userId, String username);

    SingleResult removeException(Long id, Long userId, String username);

    PageResult exceptionOrderPageList(ExceptionAllocateQueryBo bo);

    SingleResult exceptionConfirm(ExceptionConfirmBo bo, Long userId, String username);
}